package com.example.test1;

import org.openqa.selenium.By;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        //创建驱动对象
        EdgeOptions options = new EdgeOptions();
        options.addArguments("--remote-allow-origins=*");
        EdgeDriver driver = new EdgeDriver(options);
        Thread.sleep(5000);
        //在浏览器里输入百度网站，访问百度首页
        driver.get("https://www.baidu.com");
        Thread.sleep(5000);
        //找到百度首页输入框元素，并输入关键词“迪丽热巴”
        driver.findElement(By.cssSelector("#kw")).sendKeys("迪丽热巴");
        Thread.sleep(5000);
        //找到百度首页“百度一下”按钮，并点击一下
        driver.findElement(By.cssSelector("#su")).click();
        Thread.sleep(5000);
        //结束会话（关闭浏览器）
        driver.quit();
    }
}